﻿<UserControl x:Class="theeg.DependencyAnalysis.CommonAddin.Views.CheatSheet"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" Foreground="White" Background="Black" d:DesignHeight="600" d:DesignWidth="800">
    <Grid Background="Black">
        <Grid.Resources>
            <Style TargetType="Paragraph" x:Key="Header1">
                <Setter Property="FontSize" Value="20"/>
                <Setter Property="FontWeight" Value="Bold"/>
            </Style>
            <Style TargetType="Paragraph" x:Key="Header2">
                <Setter Property="FontSize" Value="16"/>
                <Setter Property="FontWeight" Value="Bold"/>
            </Style>
            <Style TargetType="Paragraph" x:Key="Header3">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="FontWeight" Value="Bold"/>
            </Style>
            <Style TargetType="Paragraph">
                <Setter Property="FontSize" Value="12"/>
                <Setter Property="FontWeight" Value="Regular"/>
                <Setter Property="Margin" Value="0,15"/>
            </Style>
        </Grid.Resources>
        <FlowDocumentReader HorizontalAlignment="Stretch" Background="{x:Null}" Foreground="White">
            <FlowDocument>
                <Paragraph Style="{StaticResource Header1}">Interaction</Paragraph>
                <Paragraph>Roll the
                    <Span Foreground="Lime">mouse wheel</Span> to
                    <Span Foreground="Lime">scroll</Span> in vertical direction.
                </Paragraph>
                <Paragraph>Roll the
                    <Span Foreground="Lime">mouse wheel</Span> while holding the
                    <Bold>[SHIFT]</Bold> key to
                    <Span Foreground="Lime">scroll</Span> in horizontal direction. This interaction applies to all
                    <Span Foreground="DeepSkyBlue">graphs</Span> .
                </Paragraph>
                <Paragraph>Press the
                    <Span Foreground="Lime">left mouse button and move cursor</Span> on a graph view. The viewport will
                    <Span Foreground="Lime">move</Span> accoring to the cursors translation. The equivalent touch gesture is holding down
                    <Span Foreground="Lime">one finger</Span> and moving it around.
                </Paragraph>
                <Paragraph>Hold the
                    <Bold>[CTRL]</Bold> key while rolling the
                    <Span Foreground="Lime">mouse wheel</Span> to
                    <Span Foreground="Lime">zoom</Span> in and out.
                </Paragraph>
                <Paragraph>Stretch or pinch
                    <Span Foreground="Lime">two fingers</Span> to
                    <Span Foreground="Lime">zoom</Span> in and out.
                </Paragraph>
                <Paragraph>In
                    <Span Foreground="DeepSkyBlue">proximity graph</Span>
                    <Span Foreground="Lime">tap or left click</Span> a
                    <Span Foreground="DeepSkyBlue">node</Span> to show references for that node.
                </Paragraph>
                <Paragraph>In
                    <Span Foreground="DeepSkyBlue">architecture graph</Span>
                    <Span Foreground="Lime">double tap or double left click</Span> a
                    <Span Foreground="DeepSkyBlue">node</Span> to show references for that node in proximity graph.
                </Paragraph>
                <Paragraph>While in
                    <Span Foreground="DeepSkyBlue">hide nodes mode</Span>
                    <Span Foreground="Lime">double tap or double left click</Span> a
                    <Span Foreground="DeepSkyBlue">node</Span> to mark that node to be hidden. Leave the mode to hide all marked nodes.
                </Paragraph>
                <Paragraph>
                    <Span Foreground="Lime">Left click or tap</Span> a
                    <Span Foreground="DeepSkyBlue">transition</Span> to open a window that lists references between the two adjacent nodes.
                </Paragraph>
                <Paragraph>
                    <Span Foreground="Lime">Left click or tap</Span> the name of an element in
                    <Span Foreground="DeepSkyBlue">metrics grid</Span> to show its references in proximity graph.
                </Paragraph>
                <Paragraph Style="{StaticResource Header1}">Columns in Metrics Grid
                </Paragraph>
                <Paragraph Style="{StaticResource Header2}">Modules
                </Paragraph>
                <List>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">D</Span> - Normed Distance from Main Sequence
                        </Paragraph>
                        <Paragraph>Describes the balance between abstractness and stability of a module. A module becomes stable when there are a lot of referrers to it. If so, then it should be abstract at the same time. A module that is instable should be concrete, as there are no referrers relying on contracts. Values are in range [-1, +1]. Close to -1 means the module is concrete but has many dependent modules, changes to the module will imply lots of changes to referrers. This is called the zone of pain. On the other side, a value of one means the module is almost completely abstract, but noone uses it. Which is the zone of uselessness.
 NormalizedDistance = Abstractness + Instability - 1
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">I</Span> - Instability
                        </Paragraph>
                        <Paragraph>Modules that contain multiple outgoing but few incoming dependencies are less stable because of the consequences of changes in these modules. Modules containing more incoming dependencies are more stable because they are more difficult to change.
 Instability = EfferentCoupling / (EfferentCoupling + AfferentCoupling)
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">A</Span> - Abstractness
                        </Paragraph>
                        <Paragraph>The portion of interfaces plus abstract types in relation to the total number of types in a module.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">RC</Span> - Relational Cohesion
                        </Paragraph>
                        <Paragraph>The average number of relations between types of the module per type. Optimal values lie between 1.5 and 4.0.
 RelationalCohesion = (RelationShips + 1) / Types
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ca</Span> - Afferent Coupling
                        </Paragraph>
                        <Paragraph>Return the number of types in other modules than the target that refer to the target module.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ce</Span> - Efferent Coupling
                        </Paragraph>
                        <Paragraph>Return the number of types the examined module depends on. The type inside the module are excluded.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Types</Span> - Number of Types
                        </Paragraph>
                        <Paragraph>The number type defined within the module.
                        </Paragraph>
                    </ListItem>
                </List>
                <Paragraph Style="{StaticResource Header2}">Submodules
                </Paragraph>
                <List>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">D</Span> - Normed Distance from Main Sequence
                        </Paragraph>
                        <Paragraph>Describes the balance between abstractness and stability of a module. A module becomes stable when there are a lot of referrers to it. If so, then it should be abstract at the same time. A module that is instable should be concrete, as there are no referrers relying on contracts. Values are in range [-1, +1]. Close to -1 means the module is concrete but has many dependent modules, changes to the module will imply lots of changes to referrers. This is called the zone of pain. On the other side, a value of one means the module is almost completely abstract, but noone uses it. Which is the zone of uselessness.
 NormalizedDistance = Abstractness + Instability - 1
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">I</Span> - Instability
                        </Paragraph>
                        <Paragraph>Submodules that contain multiple outgoing but few incoming dependencies are less stable because of the consequences of changes in these submodules. Submodules containing more incoming dependencies are more stable because they are more difficult to change.
 Instability = EfferentCoupling / (EfferentCoupling AfferentCoupling)
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">A</Span> - Abstractness
                        </Paragraph>
                        <Paragraph>The portion of interfaces plus abstract types in relation to the total number of types in a submodule.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">RC</Span> - Relational Cohesion
                        </Paragraph>
                        <Paragraph>The average number of relations between types of the submodule per type. Optimal values lie between 1.5 and 4.0.
 RelationalCohesion = (RelationShips + 1) / Types
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ca</Span> - Afferent Coupling
                        </Paragraph>
                        <Paragraph>Return the number of types in other submodules than the target that refer to the target submodule.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ce</Span> - Efferent Coupling
                        </Paragraph>
                        <Paragraph>Return the number of types the examined submodule depends on. The type inside the submodule are excluded.
                        </Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Types</Span> - Number of Types
                        </Paragraph>
                        <Paragraph>The number type defined within the submodule.
                        </Paragraph>
                    </ListItem>
                </List>
                <Paragraph Style="{StaticResource Header2}">Types
                </Paragraph>
                <List>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">LCOMHS</Span> - Lack of Cohesion Henderson Sellers</Paragraph>
                        <Paragraph>Lack of Cohesion Of Methods (LCOM): The single responsibility principle states that a class should not have more than one reason to change. Such a class is said to be cohesive. A high LCOM value generally pinpoints a poorly cohesive class.  The LCOM HS (HS stands for Henderson-Sellers) takes its values in the range [0-2]. 
 A LCOM HS value higher than 1 should be considered alarming.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Ins</Span> - Number of Instructions</Paragraph>
                        <Paragraph>Count the IL instructions of all declared members.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#F</Span> - Number of Fields</Paragraph>
                        <Paragraph>Count the number of fields in a type including inherited ones.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#IF</Span> - Number of Interfaces</Paragraph>
                        <Paragraph>Count all interface the current type implements, which equals the number of different contracts a type has to fulfill. Interfaces on inherited types and interfaces that are base types for other interfaces also count. Low values are desired.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#M</Span> - Number of Methods</Paragraph>
                        <Paragraph>Count the total number of methods in a type including inherited ones.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Ch</Span> - Number of Children</Paragraph>
                        <Paragraph>Count the number of types that inherit from the current type.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Mo</Span> - Number of overridden Methods</Paragraph>
                        <Paragraph>Count the number of methods in a type that are overriding a member of a base class.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">DIT</Span> - Depth of Inheritance</Paragraph>
                        <Paragraph>Return the depth of the inheritance tree from this type to System.Object inclusive. Interfaces do not count. Only Abstract and concrete types.

The deeper a class in the hierarchy, the greater the number of methods it will probably inherit which makes it harder to predict its behavior. Deeper trees involve greater design complexity since more classes and methods are involved. Deeper classes in the tree have a greater potential for reusing inherited methods.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">CC</Span> - Cyclomatic Complexity</Paragraph>
                        <Paragraph>The cyclomatic complexity of each member for a type are summed up. This way you have a hint to identify types that are hard to maintain.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">SIX</Span> - Specialization Index</Paragraph>
                        <Paragraph>The deeper the inheritance graph and the more members are overridden methods, the more complex a system gets. A high value of specialization is an indicator for lack of maintainability for a type and its callers.
 SIX = NumberOfOverriddenMethods * DepthOfInheritance / Max(NumberOfMethods, 1)
 A value above 1.2 should be considered alarming.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">ABC</Span> - Association between Classes</Paragraph>
                        <Paragraph>The number of members from other types that are directly accessed by the specified type.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ca</Span> - Afferent Coupling</Paragraph>
                        <Paragraph>Return the number of types that refer to the examined type. Self references are excluded.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ce</Span> - Efferent Coupling</Paragraph>
                        <Paragraph>Return the number of types the examined type depends on. Self references are excluded.</Paragraph>
                    </ListItem>
                </List>
                <Paragraph Style="{StaticResource Header2}">Members
                </Paragraph>
                <List>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">CC</Span> - Cyclomatic Complexity</Paragraph>
                        <Paragraph>The cyclomatic complexity is a measurement for the number of linear independent paths through a members source code. Fields always return 0.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Ins</Span> - Number of Instructions</Paragraph>
                        <Paragraph>Count the instructions of this member, fields return 0.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">ND</Span> - Nesting Depth</Paragraph>
                        <Paragraph>Return the deepest nesting of a members IL instructions. An implemented method at least has a nesting depth of 1 as entering the method counts as scope. Fields return 0. Anything above 5 should be considered for refactoring.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Par</Span> - Number of Parameters</Paragraph>
                        <Paragraph>Count the number of parameters of a method. For more than 2 parameters you must have good reasons. More than 3 parameters might be caused by implementing framework interfaces. Otherwise having more than 3 parameters is a hint for breaking the single responsibility principle.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">#Var</Span> - Number of Variables</Paragraph>
                        <Paragraph>Count the number of local variables in a member. Fields return 0.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ca</Span> - Afferent Coupling</Paragraph>
                        <Paragraph>Return the number of members that refer to the examined member. Self references are excluded.</Paragraph>
                    </ListItem>
                    <ListItem>
                        <Paragraph>
                            <Span Foreground="Lime">Ce</Span> - Efferent Coupling</Paragraph>
                        <Paragraph>Return the number of members the examined member depends on. The declaring type is excluded.</Paragraph>
                    </ListItem>
                </List>
            </FlowDocument>
        </FlowDocumentReader>
    </Grid>
</UserControl>
